<template>
  <div>
    <div style="display:flex;justifyContent:center;"><h1>欢迎使用权限管理模板</h1></div>
    <div>当前用户：{{username}}</div>
    <button @click="loginOut">退出</button>
    <button @click="goUser">新增管理员</button>
    <button @click="goUserList">管理员列表</button>
    <button @click="goRole">新增角色</button>
    <button @click="goRoleList">角色列表</button>
    <button @click="goMoney">新增账单</button>
    <button @click="goMoneyList">修改账单</button>
    <router-view></router-view>
    <!-- <el-row>
      <el-col :span="3">
    <h5>默认颜色</h5>
    <el-menu
      default-active="2"
      class="el-menu-vertical-demo"
      @open="handleOpen"
      @close="handleClose">
      <el-submenu index="1">
        <template slot="title">
          <i class="el-icon-location"></i>
          <span>导航一</span>
        </template>
        <el-menu-item-group>
          <template slot="title">分组一</template>
          <el-menu-item index="1-1">选项1</el-menu-item>
          <el-menu-item index="1-2">选项2</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group title="分组2">
          <el-menu-item index="1-3">选项3</el-menu-item>
        </el-menu-item-group>
        <el-submenu index="1-4">
          <template slot="title">选项4</template>
          <el-menu-item index="1-4-1">选项1</el-menu-item>
        </el-submenu>
      </el-submenu>
      <el-menu-item index="2">
        <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item>
      <el-menu-item index="3" disabled>
        <i class="el-icon-document"></i>
        <span slot="title">导航三</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-setting"></i>
        <span slot="title">导航四</span>
      </el-menu-item>
    </el-menu>
  </el-col>
      <el-col :span="21">
      <router-view></router-view>  
      <div class="grid-content bg-purple-light"></div
      ></el-col>
    </el-row>
     -->

  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      menuList: [],
      theUser: "",
    };
  },
  created() {
    //给侧边栏进行渲染
    //省略操作rightList
    //在对menuList赋值
    this.menuList = this.rightList;
    this.theUser = this.username;
  },
  computed: {
    ...mapState(["rightList", "username"]),
  },
  methods: {
    //退出登录
    loginOut() {
      //清除本地
      localStorage.clear();
      //跳转到登录页，让当前界面刷新，删除vuex中数据
      this.$router.replace("/Login");
      window.location.reload();
    },
    goRole() {
      this.$router.push("/role");
    },
    goUser() {
      this.$router.push("/user");
    },
    goUserList() {
      this.$router.push("/userList");
    },
    goRoleList() {
      this.$router.push("/roleList");
    },
    goMoney() {
      this.$router.push("/money");
    },
    goMoneyList() {
      this.$router.push("/moneyList");
    },
  },
  watch: {
    username: {
      handler(val) {
        console.log(val);
      },
      immediate: true,
      deep: true,
    },
  },
};
</script>

<style lang="scss" scoped>
.el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
</style>
